package com.ymttest.database.sqlwapper.shenqisettlement;

import java.util.HashMap;
import java.util.List;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.shenqisettlement.UserBankAccount;

public class UserBankAccountWrapper {
	
	SqlManager manager;

	public UserBankAccountWrapper() {
		manager = new SqlManager("shenqisettlement");
	}

	@SuppressWarnings("unchecked")
	public UserBankAccount selectByPrimaryKey(Long id) {

		UserBankAccount userBankAccount = new UserBankAccount();
		List<UserBankAccount> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.shenqisettlement.UserBankAccountMapper.selectByPrimaryKey",
						id);
		manager.commit();

		if (result.size() > 0) {
			userBankAccount = result.get(0);
		}

		return userBankAccount;
	}
	
	@SuppressWarnings("unchecked")
	public UserBankAccount selectByUserIdAndType(Long userId, int type) {

		UserBankAccount userBankAccount = new UserBankAccount();
		HashMap<String, Object> map = new HashMap<String, Object>();
		
		map.put("userId", userId);
		map.put("accountType", type);
		
		List<UserBankAccount> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.shenqisettlement.UserBankAccountMapper.selectByUserIdAndType",
						map);
		manager.commit();

		if (result.size() > 0) {
			userBankAccount = result.get(0);
		}

		return userBankAccount;
	}
	
	@SuppressWarnings("unchecked")
	public List<UserBankAccount> selectByUserId(Long userId) {

		HashMap<String, Object> map = new HashMap<String, Object>();
		
		map.put("userId", userId);
		
		List<UserBankAccount> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.shenqisettlement.UserBankAccountMapper.selectByUserId",
						map);
		manager.commit();

		return result;
	}
	
	@SuppressWarnings("unchecked")
	public List<UserBankAccount> selectByUserIdAndPayChannelType(Long userId, Integer payChannelType) {

		HashMap<String, Object> map = new HashMap<String, Object>();
		
		map.put("userId", userId);
		map.put("accountType", payChannelType);
		
		List<UserBankAccount> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.shenqisettlement.UserBankAccountMapper.selectByUserIdAndPayChannelType",
						map);
		manager.commit();

		return result;
	}
	
	public static void main(String[] args) {
		
		UserBankAccountWrapper wrapper = new UserBankAccountWrapper();
		
		System.out.println(wrapper.selectByUserId(500325125L).get(0));
	}
}
